package com.chchwk.remoteserver;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

public class CalculateService extends Service {
    public static final String TAG = CalculateService.class.getSimpleName();

    public CalculateService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        return mBinder;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Log.i(TAG, "onCreate");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG, "onDestroy");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.i(TAG, "onDestroy");
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public boolean onUnbind(Intent intent) {
        Log.i(TAG, "onUnbind");
        return super.onUnbind(intent);
    }

    Calculation.Stub mBinder = new Calculation.Stub() {

        @Override
        public void basicTypes(int anInt, long aLong, boolean aBoolean, float aFloat, double aDouble, String aString) throws RemoteException {

        }

        @Override
        public int addition(int a, int b) throws RemoteException {
            return a + b;
        }

        @Override
        public int subtraction(int a, int b) throws RemoteException {
            return a - b;
        }

        @Override
        public int multiplication(int a, int b) throws RemoteException {
            return a * b;
        }

        @Override
        public int division(int a, int b) throws RemoteException {
            return a / b;
        }
    };

}
